package com.stock.filter;

import com.stock.vo.ResultVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody  // 确保返回的异常是 JSON 格式
    public ResultVo handleRuntimeException(RuntimeException ex) {
        return ResultVo.error(ex.getMessage());
    }

}
